package com.cg.cgms.controller;

import com.cg.cgms.pojo.Food;
import com.cg.cgms.pojo.Result;
import com.cg.cgms.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/Food")
public class FoodController {
    @Autowired
    private FoodService foodService;
    //搜索功能，模糊查询菜品名字
    @GetMapping("/findByName")
    public Result findByName(String name){
        ArrayList<Food> foods=foodService.foodByName(name);
        return Result.succsee(foods);
    }
    //搜索功能，查询价格区间菜品
    @GetMapping("/findByMoney")
    public Result findByMoney(float minMoney,float maxMoney){
        ArrayList<Food> foods=foodService.findByMoney(minMoney,maxMoney);
        return Result.succsee(foods);
    }
    //根据店铺id查询食物属性
    @GetMapping("/foodbyssid")
    public Result foodBySsid(Integer ssid){
        ArrayList<Food> foods=foodService.foodBySsid(ssid);
        return Result.succsee(foods);
    }
}
